﻿/**
* @description  Transitions a graphic from one alpha to another.
*/
package com.foed.animation.transitions {

	import flash.display.DisplayObject;
	
	public class FadeTransition extends Transition {
		
		/**
		* @description  Constructor.
		*
		* @param  pClip  The clip on which to perform the transition.
		* @param  pStartTransform  The starting alpha value for the transition.
		* @param  pEndTransform  The destination alpha value for the transition.
		* @param  pTime  The length in milliseconds for the transition.
		* @param  pType  The type of transition. IN moves from startTransform to endTransfom. OUT does the opposite.
		* @param  pEaseFunction  The function to use to transform the transition values over time.
		*/
		public function FadeTransition(
			pClip:DisplayObject=null,
			pStartTransform:Number=0,
			pEndTransform:Number=1,
			pTime:Number=1000,
			pType:String=null,
			pEaseFunction:Function=null
		) {
			super(pClip, pTime, pStartTransform, pEndTransform, pType, pEaseFunction);
		}
	
		/**
		* @description  Called each iteration of the tween by the TweenRunner to transform values.
		*
		* @param  pChangeValues  The current values of the transition at each iteration of the tween.
		*/
		override protected function runTransition(pChangeValues:Object):void {
			clip.alpha = pChangeValues.alpha as Number;
			super.runTransition(pChangeValues);
		}
		
		/**
		* @description  Removes any artifacts from the transition.
		*/
		override protected function cleanUp():void {
			clip.alpha = 1;
			super.cleanUp();
		}

		/**
		* @description  Sets the starting alpha for the transition.
		*
		* @param  pObject  The starting alpha for the transition.
		*/
		override public function set startTransform(pObject:Object):void {
			super.startTransform = {alpha:Number(pObject)};
		}
	
		/**
		* @description  Sets the destination alpha for the transition.
		*
		* @param  pObject  The destination alpha for the transition.
		*/
		override public function set endTransform(pObject:Object):void {
			super.endTransform = {alpha:Number(pObject)};
		}

	}

}